package com.ffapp.demo.bean;


import android.text.TextUtils;

import com.amap.api.maps.model.LatLng;
import com.ffapp.demo.R;
import com.ffapp.demo.map.GPSUtil;

public class DispatchListData extends BasisBean {


    private String id;              //车辆ID
    private String name ;   //车辆名称

    private String fullName	;   //车辆全称
    private String deptId;        //部门ID
    private String deptName ;        //部门名称
    private String plateNo ;        //车牌号
    private String state ="00";        //车辆状态
    private double longitude;  //经度
    private double latitude;        //纬度
    private String speed;        //速度
    private String distance;        //距离定位点距离，参数没传为null
    private String checkTime;        //最近年检时间
    private String nextCheckTime;        //下次年检时间
    private String stateName ="待命";        //车辆状态（中文）
    private String checkAlarm;        //年检预警 1=是，0=否
    private String abbreviation;
    private boolean linearNJSIsShow = false;


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public int getNameColor(){
        switch (checkAlarm){
            case "1":
               return R.color.base_text_orange;
            default:
                return R.color.black;
        }
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getDeptId() {
        return deptId;
    }

    public void setDeptId(String deptId) {
        this.deptId = deptId;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getPlateNo() {
        return plateNo;
    }

    public void setPlateNo(String plateNo) {
        this.plateNo = plateNo;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public String getSpeed() {
        return speed;
    }

    public void setSpeed(String speed) {
        this.speed = speed;
    }

    public String getDistance() {
        return distance;
    }

    public void setDistance(String distance) {
        this.distance = distance;
    }

    public boolean isLinearNJSIsShow() {
        return linearNJSIsShow;
    }

    public void setLinearNJSIsShow(boolean linearNJSIsShow) {
        this.linearNJSIsShow = linearNJSIsShow;
    }


    public String getCheckTime() {
        if(TextUtils.isEmpty(checkTime)){
            return "";
        }
        String[] word = checkTime.split("\\s+");

        return word[0];
    }

    public void setCheckTime(String checkTime) {
        this.checkTime = checkTime;
    }

    public String getNextCheckTime() {
        if(TextUtils.isEmpty(nextCheckTime)){
            return "";
        }
        String[] word = nextCheckTime.split("\\s+");

        return word[0];
    }

    public void setNextCheckTime(String nextCheckTime) {
        this.nextCheckTime = nextCheckTime;
    }

    public String getStateName() {
        return stateName;
    }

    public void setStateName(String stateName) {
        this.stateName = stateName;
    }

    public String getCheckAlarm() {
        return checkAlarm;
    }

    public void setCheckAlarm(String checkAlarm) {
        this.checkAlarm = checkAlarm;
    }

    public String getAbbreviation() {
        return abbreviation;
    }

    public void setAbbreviation(String abbreviation) {
        this.abbreviation = abbreviation;
    }


    public LatLng getLatlng() {
        if (TextUtils.isEmpty(""+latitude) || TextUtils.isEmpty(""+longitude)) {
            return new LatLng(0, 0);
        }

        double[] gprs = GPSUtil.gps84_To_Gcj02(Double.valueOf(latitude),Double.valueOf(longitude));
        LatLng latLng = new LatLng(gprs[0], gprs[1]);
        return latLng;
    }

    public int getCheckedIndex(){
        switch (state){
            case "00":
                return 0;
            case "10":
                return 1;
            case "20":
                return 2;
            case "30":
                return 3;
            case "40":
                return 4;
            default:
                return 0;
        }
    }

    public String getStateByStateName(String name){
        switch (name){
            case "待命":
                return "00";
            case "执勤":
                return "10";
            case "维修":
                return "20";
            case "保养":
                return "30";
            case "报废":
                return "40";
            default:
                return "00";
        }
    }

    public int getStateColor(){
        switch (state){
            case "00":
                return R.color.white;
            case "10":
                return  R.color.acd77;
            case "20":
                return  R.color.base_text_grey;
            case "30":
                return  R.color.base_blue;
            case "40":
                return  R.color.base_text_grey;
            default:
                return  R.color.base_text_grey;
        }
    }

    public int getStateBackGround(){
        switch (state){
            case "00":
                return R.drawable.base_btn_green_roundcorner;
            case "10":
                return R.drawable.base_btn_green_light_roundcorner;
            case "20":
                return  R.drawable.base_btn_grey_roundcorner;
            case "30":
                return  R.drawable.base_blue_light_roundcorner;
            case "40":
                return  R.drawable.base_btn_grey_roundcorner;
            default:
                return  R.drawable.base_btn_grey_roundcorner;
        }
    }


}
